package com.yunban.project.template.controller;

import com.yunban.project.template.model.dto.BatchSaveTypeAttributeReq;
import com.yunban.project.template.model.dto.TypeAttributeReq;
import com.yunban.project.template.service.TypeAttributeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: lijiajun
 * @date: 2024-11-07
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "模板类型属性模块")
@RequestMapping("/type-attribute-api")
public class TypeAttributeController {

    @Resource
    private TypeAttributeService typeAttributeService;

    @PostMapping("/batch/save")
    @Operation(summary = "批量添加类型属性")
    Boolean batchSave(@RequestBody @Validated BatchSaveTypeAttributeReq req) {
        return this.typeAttributeService.batchSave(req);
    }

    @PostMapping
    @Operation(summary = "添加类型属性")
    Boolean saveTypeAttribute(@RequestBody @Validated TypeAttributeReq req) {
        return this.typeAttributeService.saveTypeAttribute(req);
    }

    @PutMapping("/{id}")
    @Operation(summary = "修改类型属性")
    Boolean editTypeAttribute(@PathVariable long id, @RequestBody @Validated TypeAttributeReq req) {
        return this.typeAttributeService.editTypeAttribute(id, req);
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "删除类型属性")
    Boolean delTypeAttribute(@PathVariable long id) {
        return this.typeAttributeService.delTypeAttribute(id);
    }
}
